import gtk
import conf
from engine import Widgets, XMLtree
from abcommon import *

class UI(Widgets):
	
	def __init__(self,):
		Widgets.__init__(self)
		
		self.changeXMLtree("MenuSysTray")
		self.__widget = gtk.StatusIcon()
		self.__popupMenu = self.XMLtree.getWidget("MenuSysTray")
		self.__set("Absynth FTP", "gtk-network")
		self.connectEvents()
		
	def __setPopupMenu(self, status_icon, button, activate_time):
		#if self.connection.get_status() == False:
			#popmenu.get_widget('disconnect').set_sensitive(False)
		self.__popupMenu.popup(None, None, None, button, activate_time)
		
	def __set(self, name, icon):
		self.__widget.set_tooltip(name)
		self.__widget.set_from_stock(icon)
		#self.__tray.set_from_icon_name(conf.DATA_DIR + "/img/logo_minimal.png")
		self.__widget.connect("popup_menu", self.__setPopupMenu)
		
	def connectEvents(self):
		self.XMLtree.connectSignals({
			"on_about"  : 	Invoker(Widgets.selectWidget("MainWindow").UI)._loadAboutDialog,
        	"on_destroy":	Invoker(Widgets.selectWidget("MainWindow").UI)._quitMessage,
		})